var cj;
		var i = 0;
		window.onload = function() {
			cj = setInterval("chuangjian()", 2000);
			setInterval(function() {
				i++;
				if(i >= 5) {
					clearInterval(cj);
				};
			}, 2000);
			setInterval("yidong()", 50);
		};
        
        var num=0;
		var sum=0;
		function chuangjian() {
			var div1 = document.getElementById("div1");
			var div = document.createElement("div");
			var div2 = document.createElement("div");
			div.appendChild(div2);
			div1.appendChild(div);
			div.style.backgroundImage = "url(img/ch" + parseInt(Math.random() * 3) + ".png)"
			setInterval(function(){
				div2.style.backgroundImage = "url(img/ch"+num+".png)"
				num++;
				if(num>2){
					num=0;
				}
			console.log(num);
			
				
			},300);
			setInterval(function(){
				div2.innerHTML="<img src='img/ch" +sum+ ".png' />"
				sum++;
				if(sum>2){
					sum=0;
				}
			console.log(sum);
				
			},1000);
//			div2.style.backgroundImage = "url(img/ch" + num + ".png)"
//			div2.innerHTML="<img src='img/ch" +sum+ ".png' />"
			
			div.setAttribute("t", parseInt(Math.random() * 500));
			div.setAttribute("l", parseInt(Math.random() * 1000));
			div.setAttribute("tx",parseInt(Math.random() * 5)+10);
			div.setAttribute("lx",parseInt(Math.random() * 10)+10);
		};

		function yidong() {
			var div1 = document.getElementById("div1");
			var h = document.documentElement.clientHeight;
			var w = document.documentElement.clientWidth;
			for(var k = 0; k < div1.children.length; k++) {
				var t = parseInt(div1.children[k].getAttribute("t"));
				var l = parseInt(div1.children[k].getAttribute("l"));
				var tx = parseInt(div1.children[k].getAttribute("tx"));
				var lx = parseInt(div1.children[k].getAttribute("lx"));

				t += tx;
				l += lx;

				if(t + 242 + Math.abs(tx) > h) {
					tx = -10;
				} else if(l + 242 + Math.abs(lx) > w) {
					lx = -15;
				} else if(t < 0) {
					tx = 10;
				} else if(l < 0) {
					lx = 15;
				}
				div1.children[k].style.top = t + "px";
				div1.children[k].style.left = l + "px";
				div1.children[k].setAttribute("t", t);
				div1.children[k].setAttribute("l", l);
				div1.children[k].setAttribute("tx", tx);
				div1.children[k].setAttribute("lx", lx);
			};
		};